// 引入vue
import Vue from 'vue'
// 引入vue-router
import VueRouter from 'vue-router'
// 引入需要跳转的路由文件
import routes from './routers'
// 原始 push() 方法
const originalPush = VueRouter.prototype.push
// 修改 push() 方法的定义
VueRouter.prototype.push = function (location, onComplete, onAbort) {
  if (onComplete || onAbort) {
    return originalPush.call(this, location, onComplete, onAbort)
  }
  return originalPush.call(this, location).catch(() => {})
}
Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
